#include "MainUI.h"

void MainUI::m_initLblVerse()
{
#if MOVIE_AT_STARTUP_EN
    /* 启动初 下拉时显示的文字*/
    const QString verseMsg = "天地无极，乾坤借法";
    
    QLabel* lblVerse = new QLabel(verseMsg,this);
    
    /* 设置lblVerse颜色*/
    QFont font(QString("叶根友毛笔行书2.0版"), -1, 50);
    font.setPixelSize(180);
    lblVerse->setFont(font);
    lblVerse->setStyleSheet("color:rgb(255, 170, 0)");
    lblVerse->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    
    /* 获取字符串的宽度*/
    QFontMetrics fontMetrics(font);
    int verseWidth  = fontMetrics.width(verseMsg);
    int verseHeight = fontMetrics.height();
    lblVerse->resize(verseWidth,verseHeight);
    
    lblVerse->move(geometry().width()/2-verseWidth/2-100 , -geometry().height());
#endif
}

void MainUI::m_movieAtStartup()
{
#if MOVIE_AT_STARTUP_EN
    
    static bool isRunning = true;
    static uint32_t action = 0 ;
    static uint32_t totalStep = geometry().height()*1.5F;
    static uint32_t nowStep = 0 ;
    
    if(!isRunning)
    {
        return;
    }
    
    switch(action)
    {
    case 0:
    {
        scroll(0,totalStep);
        ++action;
    }break;
    case 1:
    {
        scroll(0,-1);
        nowStep += 1;
        
        if(nowStep >= totalStep / 6)
        {
            ++action;
        }
    }break;
    case 2:
    {
        scroll(0,-10);
        nowStep += 10;
        
        if(nowStep >= totalStep)
        {
            isRunning = false;
        }
    }break;
    default:break;
    }
#endif
}


